using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;

public partial class Pub_Module_MenuVertical : System.Web.UI.UserControl
{
    public Orientation Orien ;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {           
            BindData();
        }
    }
    public Orientation SetOrientation
    {
        get{
            return Orien;
        }
        set
        {
            Orien = value;
        }
    }
     
    private void BindData()
    {
        mnVertical.Orientation = Orien;
        clsWebShop cls=new clsWebShop();
        DataSet ds=new DataSet();

        DataTable dtTopic=new DataTable();
        DataTable dtCat=new DataTable();
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("KindNo", "P");
        ds = cls.Get_Topic_Catalogue(msg.GetXmlStr);
        dtTopic = ds.Tables[0];
        dtCat = ds.Tables[1];


        string TopicID, TopicName,CatID,CatName;
        foreach(DataRow rowTopic in dtTopic.Rows)
        {
            MenuItem itemTopic=new MenuItem();
            bool flag=true;
            TopicID=rowTopic["TopicID"].ToString();
            TopicName=rowTopic["TopicName"].ToString();
            if(rowTopic["Status"]=="C")
            {
                flag = false;
                itemTopic.Text = "<a href='" + ResolveUrl("~") + "Shopping/ProductStall.aspx?List=true&TopicID=" + TopicID + "'><div  width='100%'   class='mn_Text'>" + TopicName + " &nbsp;&nbsp;<img src='" + ResolveUrl("~")+ "Images/Icon/hot.gif' border='0'></div></a>";
            }
            else
            {
                itemTopic.Text = (("<a href='" + ResolveUrl("~") +"Shopping/ProductStall.aspx?TopicID=") + TopicID + "'><div width='100%' class='mn_Text'>") + TopicName + "</div></a>";
            }            

            mnVertical.Items.Add(itemTopic);
            DataRow []rowCat;
            rowCat = dtCat.Select("TopicID=" + TopicID);

            for(int i=0;i<rowCat.Length;i++)
            {
                CatID = rowCat[i]["CatID"].ToString();
                CatName = rowCat[i]["CatName"].ToString();
                MenuItem itemCat = new MenuItem();
                if(flag == false)
                    itemCat.Text = (("<a href='" + ResolveUrl("~") + "Shopping/ProductStall.aspx?List=true&CatID=") + CatID + "'><div width='100%' class='mn_Ch_Text'>") + CatName + "</div></a>";
                else
                    itemCat.Text = (("<a href='" + ResolveUrl("~") + "Shopping/ProductStall.aspx?Kind=menu&MaTL=") + CatName + "'><div width='100%' class='mn_Ch_Text'>") + CatName + "</div></a>";

                itemTopic.ChildItems.Add(itemCat);
            }
          
        }
            
    }
}
